package xyz.wanwanwan.www.hrm._04_direct;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import xyz.wanwanwan.www.hrm.util.ConnectionUtil;

//1.创建连接
    //2.创建通道
    //3.创建交换机
    //4.创建队列
    //5.准备消息
    //6.发送消息
public class Sender {
    //交换机名
    public static final String MQ_EXCHANGE_DIRECT = "mq_exchange_direct";
    public static void main(String[] args) throws Exception {
        //1.创建连接
        Connection connection = ConnectionUtil.getConnection();
        //2.创建通道
        Channel channel = connection.createChannel();
        //3.创建交换机
        channel.exchangeDeclare(MQ_EXCHANGE_DIRECT, BuiltinExchangeType.DIRECT);
        //5.准备消息
        String message = "hello direct!!!!!!!";
        //6.发送消息
        channel.basicPublish(MQ_EXCHANGE_DIRECT,"xx",null,message.getBytes());
        System.out.println("发送成功了");
    }


}
